// pages/integral-mall/hotgoods/hotgoods.js
var page = 1;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    goods_list: [],
    overseas_id:'0',
    is_distributor:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    console.log(e)  
    var a = this
    getApp().page.onLoad(this, e)
    a.setData({
      overseas_id:e.overseas_id,
      is_distributor:e.is_distributor
    })
    page = 1, this.getGoodsList(e.cat_id);
  },

  getGoodsList: function (t) {
    var a = this;
    if(a.data.overseas_id === '3'){
     var data ={
        page: page,
        cat_id:t,
        overseas_id:3  
      }
    }else{
      var data ={
        page: page,
        cat_id:t,
      }
    }
    getApp().core.showLoading({
      title: "加载中"
    }), getApp().request({
      url: getApp().api.integral.hot_goods_list,
      data:data,
      success: function (t) {
        if (0 === t.code) {
          var e = a.data.goods_list;
          0 < t.data.list.length && (0 < e.length && (e = e.concat(t.data.list)), 0 === e.length && (e = t.data.list),
            page += 1), 0 === t.data.list.length && getApp().core.showToast({
              title: "没有更多啦",
              icon: "none"
            }), a.setData({
              goods_list: e,
            })
        }
      },
      complete: function () {
        getApp().core.hideLoading();
      }
    });
  },
  goodsInfo: function (t) {
    var e = t.currentTarget.dataset.goodsId;
    getApp().core.navigateTo({
      url: "/pages/integral-mall/goods-info/index?goods_id=" + e
    });
  },
})